import 'package:flutter/material.dart';

// ignore: must_be_immutable
class CustomButton extends StatefulWidget {
  final String text;
  bool isChange;
   CustomButton({Key key, this.text,this.isChange = false}) : super(key: key);
  @override
  _CustomButtonState createState() => _CustomButtonState();
}

class _CustomButtonState extends State<CustomButton> {
  @override
  Widget build(BuildContext context) {
    return MouseRegion(
      onEnter: (_){
        setState(() {
          widget.isChange = true;
        });
      },
      onExit: (_){
        setState(() {
          widget.isChange = false;
        });
      },
      child: RaisedButton(
        color: widget.isChange?Color.fromRGBO(97, 55, 38, 1):Color.fromRGBO(45, 60, 108, 1),
        child: Container(
            width: 80,
            height: 35,
            alignment: Alignment.center,
            child: Text(widget.text,style: TextStyle(color: Colors.white,fontSize: 18))),
        // 文本
        shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(4)),
        //圆角矩形
        onPressed: () {},
      ),
    );
  }
}
